package com.apptravel.dao;

import com.apptravel.entity.Ticket;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component("ticketDao")
public class TicketDAOImpl extends MybatisDao implements TicketDAO {

    public TicketDAOImpl() {
        super();
    }

    public int deleteById(Long id) {
        Ticket _key = new Ticket();
        _key.setId(id);
        int rows = getSqlSession().delete("ticket.deleteById", _key);
        return rows;
    }

    public void insert(Ticket record) {
        getSqlSession().insert("ticket.insert", record);
    }



    public Ticket selectById(Long id) {
        Ticket _key = new Ticket();
        _key.setId(id);
        Ticket record = (Ticket) getSqlSession().selectOne("ticket.selectById", _key);
        return record;
    }


    public int updateById(Ticket record) {
        int rows = getSqlSession().update("ticket.updateById", record);
        return rows;
    }

    public Page<Ticket> getList(Map<String,Object> params,int pageNo,int pageSize){
       params.put("page","");
       return this.selectPage("ticket.selectByMap",params,pageNo,pageSize);
    }

    public Ticket selectJoinById(Long id){
        return (Ticket)this.getSqlSession().selectOne("ticket.selectJoinById",id);
    }

    public int deleteByMap(Map<String,Object> params){
        return this.getSqlSession().delete("ticket.deleteByMap",params);
    }
}